package com.jing.weibo.service.user;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.user.UserTagsMapper;
import com.jing.weibo.pojo.user.UserTags;

/**
 * 用户标签的Service
 * @author jing.yue
 * @version 2012/10/18 1.0.0
 */
@Component
public class UserTagsService {

	@Autowired
	private UserTagsMapper userTagsMapper;

	/**
	 * 保存用户标签信息
	 * @param userSign
	 * @throws Exception
	 */
	public void saveUserTags(UserTags userTags) throws Exception {
		userTagsMapper.saveUserTags(userTags);
	}

	/**
	 * 根据标签名称查询标签对象
	 * @param name
	 * @return
	 * @throws Exception
	 */
	public UserTags findByNameUserTags(String name) throws Exception {
		return userTagsMapper.findByNameUserTags(name);
	}

	/**
	 * 分页获取标签信息
	 * @param userTags
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findUserTags(UserTags userTags) throws Exception {
		List<UserTags> userTagsList = userTagsMapper.findUserTags(userTags);
		Integer countSize = userTagsMapper.findUserTagsCount(userTags);
		PageCls pageCls = PageCls.setPageCls(userTags.getPage(), userTags.getSize(), null, null, countSize, userTagsList.size(), userTagsList);
		return pageCls.getPageInfo();
	}

}